package com.zkyc.framework.website.mapper;

import com.alibaba.fastjson.JSONObject;
import com.zkyc.framework.common.mp.EasyBaseMapper;
import com.zkyc.framework.common.pojo.Column;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * (Column)表数据库访问层
 *
 * @author libingchuan
 * @since 2022-05-25 15:04:30
 */
@Mapper
public interface ColumnMapper extends EasyBaseMapper<Column>{

    @Select("select id from web_column where moudle_id = #{moudleId}")
    List<Integer> selectByMoudleId(Integer moudleId);

    @Select("SELECT id,title FROM `web_column_data` where column_id = #{columnId} order by publish_time desc")
    List<JSONObject> selectByColumnId(Integer columnId);

    @Delete("<script>" +
            "DELETE FROM web_column WHERE moudle_id IN" +
            "    <foreach item='item' index='index' collection='moduleIdList' open='(' separator=',' close=')'>" +
            "       #{item}" +
            "    </foreach>" +
            "</script>"
    )
    int realDeleteByMoudleIds(List<Integer> moduleIdList);
}

